package org.cladwell.controller.support;

import org.Util.TkoenUtil;
import org.cladwell.exception.ConditionException;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@Component
public class UserSupport {
    public static Long getCurrentUserid(){
        ServletRequestAttributes requestAttributes= (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        String token=requestAttributes.getRequest().getHeader("token");
        Long userid= TkoenUtil.verifyToken(token);
        if(userid<=0){
            throw new ConditionException("非法用户");

        }
        return userid;
    }
}
